package my.test.annotation.resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public class FooService {
	// barServices集合有两个元素，分别是BarServiceImplOne、BarServiceImplTwo
	@Resource
	private List<BarService> b1;
	@Resource
	private BarService[] b2;
	@Resource
	private Set<BarService> b3;
	@Resource
	private Map<String, BarService> b4;
	
	@Resource(name="barServiceImplOne")
	private BarService b5;
	
	private BarService b6;

	@Resource(name="barServiceImplTwo")
	public void setBarService(BarService barService){
		this.b6 = barService;
	}

	//占位符方式
	@Value("${jdbc.url}")
	private String url;
	
	public void test() {
		System.out.println("======== List<BarService> b1 ======== ");
		System.out.println(b1);
		System.out.println("======== BarService[] b2 ======== ");
		System.out.println(b2);
		System.out.println("======== Set<BarService> b3 ======== ");
		System.out.println(b3);
		System.out.println("======== Map<String, BarService> b4 ======== ");
		System.out.println(b4);
		System.out.println("======== barServiceImplOne b5 ======== ");
		System.out.println(b5);
		System.out.println("======== setBarService b6 ======== ");
		System.out.println(b6);
		System.out.println("======== db.properties ======== ");
		System.out.println(url);
	}
}
